package com.yunhui.admin.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.yunhui.admin.model.AdminUserDateils;
import com.yunhui.entity.YCAdmin;
import com.yunhui.mapper.YCAdminMapper;


/**
 * Spring-Security
 * @author Administrator
 *
 */
@Service
public class AdminCustomerDetailsService implements UserDetailsService{

	
	@Autowired
	private YCAdminMapper yCAdminMapper;
	
	
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		YCAdmin ycAdmin= yCAdminMapper.selectYCAdminByAccount(username);
		if(ycAdmin==null) {
			
			throw new UsernameNotFoundException("未找到该用户！！");
		}
		AdminUserDateils adminUserDateils = new AdminUserDateils(ycAdmin);
		return adminUserDateils;
	}

}
